"""空调负荷监测"""
from flask import request

from air_web.web_flask.bll.monitor_bll import MonitorBll
from air_web.web_flask.common.constants import PAGE_NO, PAGE_SIZE
from air_web.web_flask.common.validator import (
    T_CHINESE,
    T_DATE,
    T_INT,
    T_LIST,
    T_STR,
    Fields,
    with_validator,
)
from air_web.web_flask.views.base_page import BasePage


class MonitorPageValidationFields:
    huanbi_fields = [
        Fields("org_no", T_STR, default="99"),
        Fields("type_code", T_INT),
        Fields("cons_no", T_STR),
        Fields("start_date", T_STR),
    ]

    alert_fields = [Fields("data_date", T_DATE)]

    graph_fields = [
        Fields("data_date", T_DATE),
        Fields("on5", T_INT),
        Fields("alert_type", T_INT),
    ]


class MonitorPage(BasePage):
    """总览页面视图函数类"""

    @classmethod
    @with_validator(request, MonitorPageValidationFields.huanbi_fields)
    def air_monitor(cls):
        validation_data = request.validation_data
        result = MonitorBll().get_air_monitor(validation_data)
        return cls.return_common_func(result)

    @classmethod
    @with_validator(request, MonitorPageValidationFields.alert_fields)
    def alert_city(cls):
        validation_data = request.validation_data
        result = MonitorBll().get_alert_city(validation_data)
        return cls.return_common_func(result)

    @classmethod
    @with_validator(request, MonitorPageValidationFields.graph_fields)
    def city_graph(cls):
        validation_data = request.validation_data
        result = MonitorBll().get_city_graph(validation_data)
        return cls.return_common_func(result)
